package com.pollux.entity;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

@Data
@NoArgsConstructor
@AllArgsConstructor
/**
 * @TableName user
 */
public class User implements Serializable {

    /*
    @NotBlank不能是空和 '' 字符串,不会会报出ConstraintViolationException异常.
    如果你只需要验证字符串的长度，使用 @Length 更加直观和简洁。
    如果你需要验证其他类型的集合或数组的大小，使用 @Size 更合适。
    两者都可以实现相同的功能，但 @Length 专用于字符串，而 @Size 适用范围更广。
    * */

    /**
     * 主键
     */
    @NotNull(message = "[主键]不能为空")
    @Schema(name = "id", description = "主键", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer id;

    /**
     * 用户名，最长11个字符长度
     */
    @NotBlank(message = "[用户名，最长11个字符长度]不能为空")
    @Size(max = 11, message = "编码长度不能超过11")
    @Schema(name = "username", description = "用户名，最长11个字符长度", requiredMode = Schema.RequiredMode.REQUIRED, maxLength = 11)
    @Length(max = 11, message = "编码长度不能超过11")
    private String username;

    /**
     * 密码，最长15位，最短8位，需要字母和数字
     */
    @NotBlank(message = "[密码，最长15位，最短8位，需要字母和数字]不能为空")
    @Size(min = 8, max = 15, message = "密码长度必须在8到15之间")
    @Schema(name = "password", description = "密码，最长15位，最短8位，需要字母和数字", requiredMode = Schema.RequiredMode.REQUIRED, minLength = 8, maxLength = 15)
    private String password;

    /**
     * 手机号
     */
    @NotBlank(message = "[手机号]不能为空")
    @Size(max = 11, message = "编码长度不能超过11")
    @Schema(name = "phone", description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, maxLength = 11)
    @Length(max = 11, message = "编码长度不能超过11")
    private String phone;

    /**
     * 注册时间
     */
    @NotNull(message = "[注册时间]不能为空")
    @Schema(name = "registTime", description = "注册时间", requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDate registTime;

    /**
     * 经验值
     */
    @NotNull(message = "[经验值]不能为空")
    @Schema(name = "experienceValue", description = "经验值", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer experienceValue;

    /**
     * 收藏夹id
     */
    @Schema(name = "collectionId", description = "收藏夹id")
    private Long collectionId;

    /**
     * 历史浏览id
     */
    @Schema(name = "historyId", description = "历史浏览id")
    private Long historyId;

    /**
     * 性别
     */
    @Schema(name = "gender", description = "性别")
    private String gender;

    /**
     * 出生时间
     */
    @Schema(name = "birthtime", description = "出生时间")
    private LocalDate birthtime;

    /**
     * 个性签名，最多50个字符
     */
    @Size(max = 50, message = "编码长度不能超过50")
    @Schema(name = "signature", description = "个性签名，最多50个字符", maxLength = 50)
    @Length(max = 50, message = "编码长度不能超过50")
    private String signature;

    /**
     * 头像
     */
    @Size(max = 255, message = "编码长度不能超过255")
    @Schema(name = "avatar", description = "头像", maxLength = 255)
    @Length(max = 255, message = "编码长度不能超过255")
    private String avatar;

    /**
     * 记录创建时间
     */
    @NotNull(message = "[记录创建时间]不能为空")
    @Schema(name = "createTime", description = "记录创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDateTime createTime;

    /**
     * 创建人id
     */
    @NotNull(message = "[创建人id]不能为空")
    @Schema(name = "createId", description = "创建人id", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer createId;

    /**
     * 最后修改时间
     */
    @NotNull(message = "[最后修改时间]不能为空")
    @Schema(name = "updateTime", description = "最后修改时间", requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDateTime updateTime = LocalDateTime.now();

    /**
     * 最后修改人id
     */
    @NotNull(message = "[最后修改人id]不能为空")
    @Schema(name = "updateId", description = "最后修改人id", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer updateId;
}
